<?php
namespace app\index\controller;
use think\Controller;

class Common extends Controller
{
	//保存管理员数据的变量
	public $info = array();

	//用户余额
	public $amount = 0;

	public function __construct()
    {
    	parent::__construct();
    	$this->checkLogin();
    }

    //判断是否已经登陆
	private function checkLogin()
	{
		$this->info = session("member_info");
		
		$this->amount = db('member')->where(['id'=>$this->info['id']])->value('amount');
		
		$set = db('set')->select();
		//计算方式
		$billing_list = db('billing')->select();

		if(!$this->info){
			$this->redirect("Login/login");
		}else{
			$this->assign("info",$this->info);
			$this->assign("amount",$this->amount);
			$this->assign("set",$set);
			$this->assign("billing_list",$billing_list);
			$this->assign("img_path",IMG_PATH);
		}
	}
}